package com.ych.modules.api.unAuthorInfc.communique.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.ych.modules.base.dbEntity.TSysCommuniqueEntity;
import com.ych.modules.base.service.ITSysCommuniqueService;
import com.ych.modules.common.entity.query.QueryCommuniqueEntity;
import com.ych.utils.mysqlPageUtil.PageUtils;
import com.ych.utils.serviceReturn.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Author: Usopp.tsui
 * Date: 2021/3/29
 * Time: 11:14
 * Description:
 */
@RestController("apiCommuniqueController")
@RequestMapping("/api/unAuth/communique")
@Api(tags = {"API——不授权公告相关"})
public class CommuniqueController {
    @Autowired
    private ITSysCommuniqueService itSysCommuniqueService;

    @ApiOperation(value = "公告列表查询", position = 1)
    @PostMapping("/listCommunique")
    public R<Page<TSysCommuniqueEntity>> listCommunique(@RequestBody QueryCommuniqueEntity entity) {
        try {
            Page<TSysCommuniqueEntity> page = itSysCommuniqueService.listCommunique(entity);
            return new R(0, "成功", new PageUtils(page));
        } catch (Exception e) {
            return new R(1, e.getMessage(), null);
        }
    }

    @ApiOperation(value = "公告详情查询", position = 1)
    @PostMapping("/getCommunique")
    public R<TSysCommuniqueEntity> getCommunique(@RequestBody String id) {
        try {
            TSysCommuniqueEntity entity = itSysCommuniqueService.getCommunique(id);
            return new R(0, "成功", entity);
        } catch (Exception e) {
            return new R(1, e.getMessage(), null);
        }
    }
}
